package com.qf.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.mapper.DtsGrouponMapper;
import com.qf.pojo.DtsGroupon;
import com.qf.service.DtsGrouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Zwnan
 */
@Service
public class DtsGrouponServiceImpl implements DtsGrouponService {
    @Autowired
    private DtsGrouponMapper dtsGrouponMapper;

    @Override
    public IPage<DtsGroupon> findPage(Integer page, Integer limit, String sort, String order) {
        IPage<DtsGroupon> iPage = new Page<>(page,limit);

        return dtsGrouponMapper.selectPage(iPage,new QueryWrapper<DtsGroupon>().eq("deleted", false));
    }

    @Override
    public void insert(DtsGroupon dtsGroupon) {
        dtsGrouponMapper.insert(dtsGroupon);
    }

    @Override
    public void update(DtsGroupon dtsGroupon) {
        dtsGrouponMapper.updateById(dtsGroupon);
    }

    @Override
    public void delete(DtsGroupon dtsGroupon) {
        dtsGroupon.setDeleted(true);
        dtsGrouponMapper.updateById(dtsGroupon);
    }
}
